home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: presby.edu!jtbell
- From: jtbell@presby.edu (Jon Bell)
- Subject: Re: Operator Overloading
- Message-ID: <DpIDqG.64M@presby.edu>
- Date: Sun, 7 Apr 1996 20:18:15 GMT
- References: <9604071905.AA001o6@lorelei.demon.co.uk>
- Organization: Presbyterian College, Clinton, South Carolina USA
-
- John Croudy <john@lorelei.demon.co.uk> wrote:
- >I then tried this:
- >
- > class MyClass
- > ...
- > operator double () const { return something; }
- > ...
- >
- >and it seems to allow me to say
- >
- > double x;
- >
- > x = MyClass;
- >
- >It seems to be a user-defined casting operator, but I can't find any
- >mention of this in any books I have. Can anyone explain what I have
- >discovered here?
-
- That's exactly what it is: a user-defined conversion (cast) from type
- 'MyClass' to type 'double'. See, for example, Lippman's "C++ Primer"
- (published by Addison-Wesley), which should be available in most good
- bookstores.
-
- --
- Jon Bell <jtbell@presby.edu> Presbyterian College
- Dept. of Physics and Computer Science Clinton, South Carolina USA
-